import APIClient from '../../network/index';

const homeSwiper = {
    state: {
        swiperList: [],
        bargainingList: [],
        specialList: [],
        specialDetails: {},
        getStoreList: [],
        shoppingList: [],
        shoppingpingjiaList:[]
    },
    mutations: {
        // 轮播
        swiper(state, item) {
            state.swiperList = [...item]
        },
        // 砍价
        bargaining(state, item) {
            state.bargainingList = item
            // console.log(state.bargainingList)
        },
        // 专题
        special(state, item) {
            state.specialList = item
        },
        // 专题详情
        specialDetails(state, item) {
            state.specialDetails = item
        },
        // 商品列表
        getStoreList(state, item) {
            state.getStoreList = item
        },
        // 商品详情
        shoppingList(state, item) {
            state.shoppingList = item
        },
        // 商品评论
        shoppingpingjia(state, item) {
            state.shoppingpingjiaList=item
        }
    },
    actions: {
        // 轮播
        swiper(context) {
            APIClient.banner().then(res => {
                // console.log(res)
                context.commit('swiper', res.data.data)
            })
        },
        // 砍价
        bargaining(context) {
            APIClient.bargaining().then(res => {
                // console.log(res)
                context.commit('bargaining', res.data.data.goodsMap)
            })
        },
        // 专题
        special(context) {
            APIClient.special().then(res => {
                // console.log(res)
                context.commit('special', res.data.data)
            })
        },
        // 专题详情
        specialDetails(context, id) {
            APIClient.specialDetails(id).then(res => {
                // console.log(res)
                context.commit('specialDetails', res.data.data)
            })
        },
        // 商品列表
        getStoreList(context,id) {
            APIClient.getStoreList(id).then(res => {
                // console.log(res)
                context.commit('getStoreList', res.data.data)
            })
        },
        // 商品详情
        shopping(context, id) {
            APIClient.shopping(id).then(res => {
                // console.log(res.data.data)
                context.commit('shoppingList', res.data.data)
            })
        },
        // 商品评价
        shoppingpingjia(context, id) {
            APIClient.shoppingpingjia(id).then(res => {
                // console.log(res.data.data)
                context.commit('shoppingpingjia', res.data.data)
            })
        }
    },
    modules: {}
}
export default homeSwiper